package com.kele.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author chunhui.li
 * @date 2021/10/25 18:06
 * @Description
 * @ClassName MyMetaObjectHandler
 */
@Slf4j
@Component


public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override

    public void insertFill(MetaObject metaObject) {

        log.info("开始创建时间字段...");



        this.setFieldValByName("createTime",new Date(),metaObject);

        this.setFieldValByName("updateTime",new Date(),metaObject);

    }



    @Override

    public void updateFill(MetaObject metaObject) {

        log.info("开始更新时间字段...");



        this.setFieldValByName("updateTime",new Date(),metaObject);

    }

}

